package serial;
import java.io.File;

import java.io.IOException;

import java.io.OutputStream;

import java.util.Scanner;



public class SerialWriter {

	private OutputStream out;

    

    public SerialWriter (OutputStream out) {

        this.out = out;

    }


    // Returns number of lines sent
    public void send(String output) throws IOException {
    	for (int i = 0; i < output.length(); ++i) {
    		out.write(output.codePointAt(i));
    	}
    }

    public void send(File f) throws IOException {

    	Scanner s = new Scanner(f);

		while (s.hasNextLine()) {

			send(s.nextLine() + "\n");

		}

    }
    
    public void close() throws IOException {
    	out.close();
    }

}

